<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $model common\models\business\BusinessPig */

$this->title = $model->no;
$this->params['breadcrumbs'][] = ['label' => 'Business Pigs', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
              <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">

                <div class="business-pig-view">

                    <p>
                        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
                        <?= Html::a('删除', ['delete', 'id' => $model->id], [
                            'class' => 'btn btn-danger',
                            'data' => [
                                'confirm' => '您确定删除此项吗?',
                                'method' => 'post',
                            ],
                        ]) ?>
                    </p>

                    <?= DetailView::widget([
                        'model' => $model,
                        'attributes' => [
                        'no',
                         'unino',
                        'weight',
                        'height',
                        'activelevel',
                        'haircolor',
                        'foodintake',
                        'shit',
                        'breath',
                        'temperature',
                         'price',
                        'cost',
                        [
                            'attribute' => 'varietyid',
                            'value' => function($model){
                                return $model->variety?$model->variety->title:'';
                            }
                        ],
                        'batch',
                        [
                            'attribute'=>'beforevaccinetime',
                            'format'=>['date','php:Y-m-d'],

                        ],
                        [
                                'attribute'=>'aftervaccinetime',
                                'format'=>['date','php:Y-m-d'],

                        ],
                        [
                            'attribute'=>'intime',
                            'format' => ['date', 'php:Y-m-d'],
                            'value'=>function($model){
                                    return $model->intime?$model->intime:'';
                            }
                        ],
                        [
                            'attribute'=>'planout',
                            'format'=>['date','php:Y-m-d'],
                        ],

                        [
                            'attribute' => 'livery',
                            'value' => function($model){
                                return $model->liveryperson?$model->liveryperson->name:'';
                            }
                        ],
                        'gender',
                        [
                            'attribute' => 'status',
                            'value' => function($model){
                                return \common\models\business\BusinessPig::$statues[$model->status];
                            }
                        ],
                        [
                            'attribute'=>'mathor',
                            'value' => function($model){
                                return $model->file?$model->file->mathor:'';
                            }
                        ],
                        [
                            'attribute'=>'father',
                            'value' => function($model){
                                return $model->file?$model->file->father:'';
                            }
                        ],
                        [
                            'attribute' => 'fileid',
                            'value' => function($model){
                                return $model->file?$model->file->no:'';
                            }
                        ],
                        [
                            'attribute'=>'photo',
                            'format'=>'raw',
                            'value'=>function($model){
                                $html = '';
                                $ps = \common\components\Upload::checkGetUrl($model->photo,true,'photo');
                                foreach ($ps as $key => $row){
                                    $html .= yii\helpers\Html::img(\common\components\Upload::checkGetUrl($row),['alt' => '缩略图','width' => 100 ,'height' => 100,'style'=>'margin:10px;']);
                                }
                                return $html;
                            }
                        ],
                        [
                            'attribute'=>'screen_photo',
                            'format'=>'raw',
                            'value'=>function($model){
                                $html = '';
                                $ps = \common\components\Upload::checkGetUrl($model->screen_photo,true,'screen_photo');
                                foreach ($ps as $key => $row){
                                    $html .= yii\helpers\Html::img(\common\components\Upload::checkGetUrl($row),['alt' => '缩略图','width' => 100 ,'height' => 100,'style'=>'margin:10px;']);
                                }
                                return $html;
                            }
                        ],
                        ],
                    ]) ?>
                    <table id="w0" class="table table-striped table-bordered detail-view">
                        <tbody>
                            <tr><th>二维码</th><td><img src="<?php echo Url::to(['/business/pig/qrcode','no'=>$model->no]) ?>" width="100" height="100" alt="二维码"></td></tr>
                        </tbody>
                    </table>


                </div>
            </div>
        </div>
    </section>
</section>